package com.kefu.call.vo;

import org.apache.commons.lang3.StringUtils;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.kefu.common.vo.AbstractSearchVo;
import com.kefu.call.model.CallSipuser;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
 * @author CodeGenerator
 * @date 2022/07/24
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@ApiModel(description = "SIP用户")
public class CallSipuserSearchVo extends AbstractSearchVo {

    @ApiModelProperty(value = "账号")
    private String sipUser;
    @ApiModelProperty(value = "密码")
    private String password;
    @ApiModelProperty(value = "虚拟密码")
    private String vmPassword;
    @ApiModelProperty(value = "允许")
    private String tollAllow;
    @ApiModelProperty(value = "账户代码")
    private String accountcode;
    @ApiModelProperty(value = "用户联系地址")
    private String userContext;
    @ApiModelProperty(value = "有效的呼叫者号码")
    private String effectiveCallerIdName;
    @ApiModelProperty(value = "有效的呼叫者号码")
    private String effectiveCallerIdNumber;
    @ApiModelProperty(value = "出站呼叫者姓名")
    private String outboundCallerIdName;
    @ApiModelProperty(value = "呼出号码")
    private String outboundCallerIdNumber;
    @ApiModelProperty(value = "呼叫组")
    private String callgroup;
    @ApiModelProperty(value = "呼叫组ID")
    private Integer callgroupid;
    @ApiModelProperty(value = "组名")
    private String groupname;
    @ApiModelProperty(value = "是否开启留言")
    private Integer voicemail;
    @ApiModelProperty(value = "是否bypass模式")
    private Integer bypass;
    @ApiModelProperty(value = "是否需要录音")
    private Integer needrecord;
    @ApiModelProperty(value = "规则")
    private String dialplanName;
    @ApiModelProperty(value = "是否开启转接")
    private Integer transferenable;
    @ApiModelProperty(value = "转接模式[all:全部转接 busy:遇忙转接 noAnswer:没有应答转接 offLine:不在线转接]")
    private String transfermodel;
    @ApiModelProperty(value = "转接的方式,默认走【n.lua】流程")
    private String transfercontent;
    @ApiModelProperty(value = "是否开启nat重写IP和端口")
    private Integer sipForceContact;
    @ApiModelProperty(value = "公司id")
    private String company;

    @Override
    public LambdaQueryWrapper<CallSipuser> lambdaQuery() {
        LambdaQueryWrapper<CallSipuser> wrapper = Wrappers.<CallSipuser>lambdaQuery();
        wrapper.like(StringUtils.isNotBlank(sipUser), CallSipuser::getPassword, sipUser);//账号
        wrapper.eq(StringUtils.isNotBlank(password), CallSipuser::getPassword, password);//密码
        wrapper.eq(StringUtils.isNotBlank(vmPassword), CallSipuser::getVmPassword, vmPassword);//虚拟密码
        wrapper.eq(StringUtils.isNotBlank(tollAllow), CallSipuser::getTollAllow, tollAllow);//允许
        wrapper.eq(StringUtils.isNotBlank(accountcode), CallSipuser::getAccountcode, accountcode);//账户代码
        wrapper.eq(StringUtils.isNotBlank(userContext), CallSipuser::getUserContext, userContext);//用户联系地址
        wrapper.eq(StringUtils.isNotBlank(effectiveCallerIdName), CallSipuser::getEffectiveCallerIdName, effectiveCallerIdName);//有效的呼叫者号码
        wrapper.eq(StringUtils.isNotBlank(effectiveCallerIdNumber), CallSipuser::getEffectiveCallerIdNumber, effectiveCallerIdNumber);//有效的呼叫者号码
        wrapper.eq(StringUtils.isNotBlank(outboundCallerIdName), CallSipuser::getOutboundCallerIdName, outboundCallerIdName);//出站呼叫者姓名
        wrapper.eq(StringUtils.isNotBlank(outboundCallerIdNumber), CallSipuser::getOutboundCallerIdNumber, outboundCallerIdNumber);//呼出号码
        wrapper.eq(StringUtils.isNotBlank(callgroup), CallSipuser::getCallgroup, callgroup);//呼叫组
        wrapper.eq(callgroupid != null, CallSipuser::getCallgroupid, callgroupid);//呼叫组ID
        wrapper.eq(StringUtils.isNotBlank(groupname), CallSipuser::getGroupname, groupname);//组名
        wrapper.eq(voicemail != null, CallSipuser::getVoicemail, voicemail);//是否开启留言
        wrapper.eq(bypass != null, CallSipuser::getBypass, bypass);//是否bypass模式
        wrapper.eq(needrecord != null, CallSipuser::getNeedrecord, needrecord);//是否需要录音
        wrapper.eq(StringUtils.isNotBlank(dialplanName), CallSipuser::getDialplanName, dialplanName);//规则
        wrapper.eq(transferenable != null, CallSipuser::getTransferenable, transferenable);//是否开启转接
        wrapper.eq(StringUtils.isNotBlank(transfermodel), CallSipuser::getTransfermodel, transfermodel);//转接模式[all:全部转接 busy:遇忙转接 noAnswer:没有应答转接 offLine:不在线转接]
        wrapper.eq(StringUtils.isNotBlank(transfercontent), CallSipuser::getTransfercontent, transfercontent);//转接的方式,默认走【n.lua】流程
        wrapper.eq(sipForceContact != null, CallSipuser::getSipForceContact, sipForceContact);//是否开启nat重写IP和端口
        wrapper.eq(StringUtils.isNotBlank(company), CallSipuser::getCompany, company);//公司id

        return wrapper;
    }
}